package com.apes.fa.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = FaAssetInventoryItem.CONST_TABLE_NAME)
public class FaAssetInventoryItem extends Model {

    public static final String CONST_TABLE_NAME = "fa_asset_inventory_item";

    @Id
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "资产盘点明细", padding = 8)
    @Comment("明细编号")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fa_card_Id", referencedColumnName = "id")
    @Comment("资产卡片")
    private FaCard faCard;

    @Column(name = "product_id")
    @Comment("商品卡片编号")
    private String productId;

    @Column(name = "product_name")
    @Comment("商品名称")
    private String productName;

    @Column(name = "cost_center_name")
    @Comment("成本中心名称")
    private String costCenterName;

    @Column(name = "book_quantity")
    @Comment("账面数量")
    private Integer bookQuantity;

    @Column(name = "actual_quantity")
    @Comment("实存数量")
    private Integer actualQuantity;

    @Column(name = "inventory_profit_quantity")
    @Comment("盘盈数量")
    private Integer inventoryProfitQuantity;

    @Column(name = "replay_quantity")
    @Comment("复盘数量")
    private Integer replayQuantity;

    @Column(name = "replay_difference")
    @Comment("复盘差异")
    private Integer replayDifference;

    @Column(name = "processed_quantity")
    @Comment("已处理数量")
    private Integer processedQuantity;

    @Column(name = "fa_status")
    @Comment("资产状态")
    private String faStatus;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fa_asset_inventory_id", referencedColumnName = "id", nullable = false)
    @Comment("资产盘点")
    private FaAssetInventory faAssetInventory;

}
